package org.skyemoon.hbase.hbasetest.toolkit;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * Date转String工具类
 */
public class Date2String {

    /**
     * Date转String
     * @param date
     * @return
     */
    public static String convertDate2String(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    /**
     * String转Date
     * @param value
     * @return
     */
    public static Date convertString2Date(String value) throws ParseException {

        SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
        String replace = value.replace("\uFEFF", "");
        System.out.println(replace);
        return dateFormat.parse(replace);
    }
}
